home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / other-tools / varexx / demo / demo.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1992-09-02  |  5.7 KB  |  205 lines

  1. /* Demo Script */
  2.     guifile = 'test.gui'
  3.  
  4.     options results
  5.     launchvarexx = FALSE
  6.  
  7.     /* Open libs needed */
  8.     if ~show("L","rexxsupport.library") then
  9.         if ~addlib("rexxsupport.library", 0, -30) then exit
  10.  
  11.     if ~show("L","rexxreqtools.library") then
  12.         if ~addlib("rexxreqtools.library", 0, -30) then exit
  13.  
  14.     /* Check Varexx is loaded if not load it */
  15.  
  16.     if show( 'p', 'VAREXX' ) ~= 1 then do
  17.         address command 'run varexx'
  18.         waitforport VAREXX
  19.         launchvarexx = TRUE
  20.     end
  21.     address VAREXX
  22.  
  23.     /* Open the port for gui to talk to */
  24.     call openport("WINDOWPORT")
  25.  
  26.     /* Load the gui file into varexx */
  27.     'load 'guifile' WINDOWPORT'
  28.  
  29.     /* Set host to the port for this gui file */
  30.     host = result 
  31.     address value host
  32.  
  33.     /* Display the window */
  34.     show 
  35.     busy set
  36.     call message('Varexx opens Gadtoolsbox Gui files and can set the busy pointer.')
  37.  
  38.     call message('The multiple choice options can be set.')
  39.     setnum one 2
  40.     setnum cycle 2
  41.  
  42.     call message('The sliders and scrollers can be moved.')
  43.     setnum scroll 10
  44.     setnum slider 10
  45.  
  46.     call message('And their other values altered.')
  47.     setbar scroll min 50 max 150
  48.     setbar slider min 0 max 100
  49.  
  50.     call message('Fixed text and number gadget can be filled.')
  51.     settext text 'Amiga'
  52.     setnum noview 4000
  53.  
  54.     call message('as can the editable ones.')
  55.     settext gad1 'You could change this.'
  56.     setnum num 2001
  57.  
  58.     call message('Checking check boxes.')
  59.     setcheck gad2 check
  60.  
  61.     call message('Add items to listviews.')
  62.     'setlist LIST Haddock Cod Place Skate Herring Tuna'
  63.  
  64.     call message('Opps. You can get rid of them as well')
  65.     'setlist LIST Place del'
  66.  
  67.     call message('and select them.')
  68.     'setlist LIST select Cod'
  69.  
  70.     call message('Clear the list and start again.')
  71.     'setlist LIST clear Monday Tuesday Wednesday Thursday Friday'
  72.  
  73.     call message('Disable gadgets')
  74.     set slider cycle scroll gad1 gad2 num okay list one file pallete disable
  75.  
  76.     call message('and guess what -- Enable them too.')
  77.     set slider cycle scroll gad1 gad2 num okay list one file pallete enable
  78.  
  79.     fish = 'You can also react to the user.' || '0a'x
  80.     fish = fish||  'Click Onwards and play with the GUI and' || '0A'x
  81.     fish = fish || 'watch the shell. Click Okay to continue.' || '0a'x
  82.     fish = fish || 'Keyboard shortcuts as well.'
  83.  
  84.     call message( fish )
  85.  
  86.     busy
  87.     do forever
  88.         call waitpkt( "WINDOWPORT" )
  89.  
  90.         packet = getpkt( "WINDOWPORT" )
  91.  
  92.  
  93.         if packet ~= '00000000'x then do 
  94.             class  = getarg(packet)
  95.             type = word( class, 1)
  96.             msg = substr( class, length( type ) + 1 )
  97.  
  98.             select
  99.                 when type = closewindow then say 'Clicked on close gadget.'
  100.                 when type = okay    then leave
  101.                 when type = list    then say 'List selected 'msg
  102.                 when type = cycle   then say 'Cycle gadget option 'msg
  103.                 when type = one     then say 'Multiple Choice gadget option 'msg
  104.                 when type = scroll  then say 'Scroller now at 'msg
  105.                 when type = slider  then say 'Slider now at 'msg
  106.                 when type = gad1    then say 'You typed in 'msg
  107.                 when type = num     then say 'Your number is 'msg
  108.                 when type = palette then say 'Colour #'msg
  109.                 when type = gad2    then say 'Check is 'msg
  110.                 when type = file    then do
  111.                     dict = rtfilerequest(, ,'Select a file' , , 'rt_reqpos = reqpos_centerscr')
  112.                     settext gad1 dict
  113.                 end
  114.                 otherwise say class
  115.             end
  116.  
  117.         end
  118.     end
  119.  
  120.     call message( ' Lets us proceed. Try the Zoom Gadget...' )
  121.     window zip
  122.     fish = 'That was Pos zoom. Varexx supports most' || '0a'x
  123.     fish = fish || 'of the options that can be set in GadToolsBox.' || '0a'x
  124.     fish = fish || 'Varexx adapts to fonts and resolutions.'
  125.     call message( fish )
  126.  
  127.     busy set
  128.  
  129.     call message( 'Your arexx script can read from Varexx Gadgets.')
  130.     
  131.     read one
  132.     fish = 'Multiple Choice option = 'result || '0a'x
  133.     read cycle
  134.     fish = fish || 'Cycle gadget option = 'result || '0a'x
  135.     read slider
  136.     fish = fish || 'Slider at 'result || '0a'x
  137.     read scroll
  138.     fish = fish || 'Scroller at 'result 
  139.     call message( fish )
  140.  
  141.     read gad1
  142.     fish = 'You typed : 'result || '0a'x
  143.     read num 
  144.     fish = fish || 'Number entered : 'result || '0a'x
  145.     read palette
  146.     fish = fish || 'Palette colour : 'result || '0a'x
  147.     read gad2
  148.     fish = fish || 'Check is 'result
  149.     call message( fish )
  150.  
  151.     read list
  152.     if result = 'RESULT' then do
  153.         call message( 'No item is selected in the list. But you can...')
  154.     end; else; do
  155.         call message( 'For lists the selected item is 'result' or...')
  156.     end
  157.  
  158.     read list var h 
  159.     fish = 'List all items...' 
  160.     do n = 1 to h.count
  161.         fish = fish || '0a'x || h.n
  162.     end
  163.     drop h
  164.  
  165.     call message( fish )
  166.     'hide'
  167.     call message( 'Windows can be hidden')
  168.     'show next'
  169.     call message( 'and if there is more than one in a GUI file.' )
  170.  
  171.     /* Create the context for a new window */
  172.     'spawn WINDOWPORT'
  173.     vhost2 = RESULT
  174.     address value vhost2
  175.  
  176.     /* Show the second window */
  177.     'show'
  178.     address
  179.  
  180.     /* Move the other forwards */
  181.     'window front'
  182.  
  183.     call message( 'Both on screen at once !' )
  184.  
  185.     /* Unload and remove both windows */
  186.     'hide unload'    
  187.     address
  188.     'hide unload'
  189.  
  190.     call message('That is all. I Hope you liked it.')
  191.  
  192.     call closeport( "WINDOWPORT" )
  193.  
  194.     if launchvarexx = TRUE then address command vxc
  195.  
  196. exit
  197.  
  198. message : procedure
  199.     call rtezrequest( arg(1),'Onwards','Varexx (Patronizing) Demo','rt_reqpos = reqpos_topleftscr rtez_flags=ezreqf_centertext',)
  200. return
  201.  
  202.  
  203.  
  204.  
  205.